
<template>
  <h2 style="text-align: center">用户登录</h2>
  <van-form @submit="onSubmit">
    <van-cell-group inset>
      <van-field
        v-model="formData.username"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="formData.password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
    </van-cell-group>
    <div style="margin: 16px">
      <van-button round block type="primary" native-type="submit">
        提交
      </van-button>
    </div>
  </van-form>
</template>
<script setup >
import { reactive } from "vue";
import { loginApi } from "@/api";
const formData = reactive({
  username: "13397101182",
  password: "123456",
});
const onSubmit = async () => {
  console.log(123);
  const res = await loginApi(formData);
  showNotify({ message: res.message });
  if (res.code === 10000) {
    localStorage.setItem("token", res.data.token);
    router.push("/");
  }
  console.log(res, "res");
};
</script>
<style lang='less' scoped></style>